package com.example.lte.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Comparator;

@Entity
@Table(name = "lte_menu",uniqueConstraints = @UniqueConstraint(columnNames = {"note","routerName","routerPath"}) )
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MenuEntity {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long menuId;

    @Column(length = 64)
    private String note;

    @Column(name = "menuSequence", columnDefinition = "bigint COMMENT '菜单排序号;控制菜单展示的前后顺序'")
    private Long menuSequence;


    @Column(name = "parentMenuId", columnDefinition = "bigint COMMENT '父级菜单Id'")
    private Long parentMenuId;

    @Column(name = "menuLevel", columnDefinition = "bigint COMMENT '菜单层级: 1->一级菜单;2->二级菜单'")
    private Long menuLevel;

    @Column(name = "hasChild", columnDefinition = "bigint COMMENT '是否含有子菜单: 0->否;1->是'")
    private Long hasChild;

    @Column(name = "isMenu", columnDefinition = "bigint COMMENT '作为菜单显示: 0->否;1->是'")
    private Long isMenu;

    /**
     *  {
     *         path: '/home',
     *         name: 'Home',
     *         component: Home
     *     },
     */

    @Column(length = 100)
    private String routerName;

    @Column(length = 80)
    private String iconType;

    @Column(length = 80)
    private String menuKey;

    @Column(length = 100)
    private String routerPath;

    @Column(length = 100)
    private String routerComponent;


    @CreationTimestamp
    @Column(name = "add_time", columnDefinition = "DATETIME COMMENT '添加时间'")
    private Timestamp addTime;

    @UpdateTimestamp
    @Column(name = "update_time", columnDefinition = "DATETIME COMMENT '最后更新时间'")
    private Timestamp updateTime;


    @Version
    @Column(name = "version", columnDefinition = "bigint COMMENT '版本号'")
    private Long version;

}
